﻿var screenWidth = 600;
var screenHeight = 400;
var debugMode = false;

function launchApp(launchData) {

    console.log('application started');
    console.log("launchData=" + launchData);
    getDisplaySize();
    
    startViewer();
}

function startViewer() {
    console.log('debugMode = ' + debugMode + ' | screenWidth = ' + screenWidth + ' | screenHeight = ' + screenHeight);
	
	var windowOptions = {
		        'frame': 'none',
		        'left': 0,
		        'top': 0,
		        'width': screenWidth,
		        'height': screenHeight
		    };
	 
	windowOptions.state = debugMode ? 'normal' : 'maximized';

    chrome.app.window.create('index.html', windowOptions,
    function (win) {
        win.contentWindow.launchData = {'debugMode': debugMode};
    });
}


function getDisplaySize() {
	
//	if (!chrome.system.display) return;
//		
//    chrome.system.display.getInfo(function(displayInfoList) {
//        for (var i = 0; i < displayInfoList.length; i++) {
//        	var di = displayInfoList[i];
//            console.log('display=', di);
//        }
//    });
}

chrome.app.runtime.onLaunched.addListener(launchApp);
